﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HiLand.General.Entity;
using HiLand.General.BLL;
using HiLand.Utility.Enums;

namespace Legou365.Web.Controllers
{
    public class ProductController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 获取最热商品（目前列出的是置顶商品，以后修改算法规则按照销售量进行统计）
        /// </summary>
        /// <returns></returns>
        public ActionResult ProductHotList()
        {
            List<SimpleProductEntity> productList = SimpleProductBLL.Instance.GetList(string.Format("productIsTop={0}", (int)Logics.True));
            return View(productList);
        }

        /// <summary>
        /// 商品详细信息
        /// </summary>
        /// <param name="productGuid"></param>
        /// <returns></returns>
        public ActionResult ProductDetails(Guid productGuid)
        {
            return View(GetProduct(productGuid));
        }


        /// <summary>
        /// 商品滚动展示
        /// </summary>
        /// <returns></returns>
        public ActionResult _ProductScroller()
        {
            List<SimpleProductEntity> productList = SimpleProductBLL.Instance.GetList(string.Format("productIsTop={0}", (int)Logics.True));
            return View(productList);
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="productGuid"></param>
        /// <returns></returns>
        public ActionResult _ProductItemLargeFeature(Guid productGuid)
        {
            return View(GetProduct(productGuid));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="productGuid"></param>
        /// <returns></returns>
        public ActionResult _ProductItemBigFeature(Guid productGuid)
        {
            return View(GetProduct(productGuid));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="productGuid"></param>
        /// <returns></returns>
        public ActionResult _ProductItemSmallFeature(Guid productGuid)
        {
            return View(GetProduct(productGuid));
        }

        #region 辅助方法
        /// <summary>
        /// 获取产品信息
        /// </summary>
        /// <param name="productGuid"></param>
        /// <returns></returns>
        [NonAction]
        private SimpleProductEntity GetProduct(Guid productGuid)
        {
            SimpleProductEntity entity = null;

            if (productGuid != Guid.Empty)
            {
                entity = SimpleProductBLL.Instance.Get(productGuid);
            }
            else
            {
                entity = new SimpleProductEntity();
            }

            return entity;
        }
        #endregion
    }
}
